<?php $this->load->view('header')?>
		<link href="/css/sso.css" rel="stylesheet" type="text/css">
		<link href="/css/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css">	
		<script src="/js/jquery/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
		<script language="Javascript" type="text/javascript">	
	
			var Validator = {
				//检查EMAIL
				isEmail: function (str){	
					  var reg =  /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
					  var flag = reg.test(str);
					  return flag;
				},		
				isMobileNum: function(str){
					//var reg = /^1\d{10}$/;
					var reg = /^((852\d{8})|(((\(\d{2,3}\))|(\d{3}\-))?((13\d{9})|(15\d{9})|(18\d{9}))))$/;
					var flag = reg.test(str);
					return flag;
				},		
				//检查是否字母
				isAlpha: function (str){
				  var reg = /^[A-z]+$/;
				  var flag = reg.test(str);
				  return flag;
				},	
				//检查是否字母或数字
				isAlphaNumeric: function (str){
				  var reg = /^[0123456789A-z]+$/;
				  var flag = reg.test(str);
				  return flag;
				},	
				//检查是否字母或数字或中划线下划线
				isAlphaDash: function (str){
				  var reg = /^[-_0123456789A-z]+$/;
				  var flag = reg.test(str);
				  return flag;
				},		
				//检查是否数值
				isNumeric: function (str){
				  var reg = /^-?[0-9]+\.?[0-9]*$/;
				  var flag = reg.test(str);
				  return flag;},		
				//检查是否数字
				isDigital: function (str){
				  var reg = /^[0-9]+$/;
				  var flag = reg.test(str);
				  return flag;},
					// 检查是否小于
				isLess: function(str, num){
					return str.length < num;},	
				// 检查是否大于
				isMore: function(str, num){
					return str.length > num;},	
				PWD_TOO_LONG: "请输入6～16位数字+字母组合",
				PWD_TOO_SHORT: "请输入6～16位数字+字母组合",
				PWD_TOO_SIMPLE: "密码过于简单，请输入字母与数字的组合",
				CONFIRM_PWD_MISMATCHED: "两次输入的密码不一致",
				VALID_MOBILE_NUM: "手机号码的格式不对",
				IS_REQUIRED: "请输入",
				VALID_EMAIL: "请输入有效的邮箱地址",
				EMAIL_TOO_LONG: "邮箱地址太长，请输入有效的邮箱地址",
				COMPANY_NAME_TOO_LONG: "公司名字过长，请输入不超过50个字符",
				COMPANY_URL_TOO_LONG: "公司主页链接过长，请输入不超过200个字符",
				DONT_AGREE: "您没有同意服务协议"
			}
		</script>
		<!-- image path -->
		<!-- set i18n -->
		<!-- timeZone offset localOffset -->
		<script type="text/javascript">
			// create Date object for current location
			globaldate = new Date();
			// obtain local UTC offset and convert to msec
			localOffset = globaldate.getTimezoneOffset() * 60000;
		</script>
		<script type="text/javascript">
			$(document).ready(function(){
				$("#cur_ul > li > input").bind("blur",function(){
						$("#cur_ul > li > input").removeClass("cur");});
				$("#cur_ul > li > input").bind("focus",function(){
						$(this).addClass("cur");});
				$("#reg_form").submit(function() {
					if ($("#isAgree:checked").size() == 0) {
						alert("请先看过并同意《Testin通行证用户服务协议》");
						return false;
					}
				});
				$("#email").focus(function(){
							cleanDefEmail();
							clearRegEmailErrMsg();
						}).blur(function(){
							clearRegEmailErrMsg();
							setDefEmail();
							validRegEmail();
				});
				setDefEmail();
			});
			function validRegEmail() {
			 var strm = $.trim($("#email").val());
				     if(""==strm || strm == SAMPLE_EMAIL) {
				      $("#err_reg_email").css("display","block");
				      $("#err_reg_email").text(Validator.IS_REQUIRED + "邮箱地址");
						return false;
					}
					if (Validator.isMore(strm, 50)) {
					 $("#err_reg_email").css("display","block");
					 $("#err_reg_email").text(Validator.EMAIL_TOO_LONG);
					 return false;
					}
				 if (!Validator.isEmail(strm)) {
				  $("#err_reg_email").css("display","block");
				 	$("#err_reg_email").text(Validator.VALID_EMAIL);
						return false;
				 }
				return true;
			}
			function validRegPwd() {
				var strm =$("#pwd").val();		
			    if(""==strm) {
			    	 $("#err_reg_pwd").css("display","block");
			    	$("#err_reg_pwd").text(Validator.IS_REQUIRED + "密码");
					return false;
				}
				if(Validator.isLess(strm, 6)) {
				 	 $("#err_reg_pwd").css("display","block");
				 	$("#err_reg_pwd").text(Validator.PWD_TOO_SHORT);
					return false;
				}
				if(Validator.isMore(strm, 16)) {
				 	$("#err_reg_pwd").css("display","block");
				 	$("#err_reg_pwd").text(Validator.PWD_TOO_LONG);
					return false;
				}
				if(Validator.isDigital(strm) || Validator.isAlpha(strm)) {
				  $("#err_reg_pwd").css("display","block");
				  $("#err_reg_pwd").text(Validator.PWD_TOO_SIMPLE);
				  return false;
				}
				 return true;
			}	
			function validConfimPwd(){
				 var confimPwd = $.trim($("#confimPwd").val());
				  if(""==confimPwd) {
				   $("#err_reg_confimPwd").css("display","block");
					 $("#err_reg_confimPwd").text(Validator.IS_REQUIRED + "确认密码");
						return false;
					}	
				 var pwd = $.trim($("#pwd").val());
				 if (confimPwd != pwd) {
				  $("#err_reg_confimPwd").css("display","block");
					$("#err_reg_confimPwd").text(Validator.CONFIRM_PWD_MISMATCHED);
						return false;
				 }
				 return true;
			}
			function validComName() {
			var comName =  $.trim($("#comName").val());
			if (Validator.isMore(comName, 50)) {
			    $("#err_reg_comName").css("display","block");
			 	$("#err_reg_comName").text(Validator.COMPANY_NAME_TOO_LONG);
					return false;
			    }
			   	return true;
			}	
			function validComUrl() {
				var comUrl =  $.trim($("#comUrl").val());
				if (Validator.isMore(comUrl, 200)) {
				 $("#err_reg_comUrl").css("display","block");
				 	$("#err_reg_comUrl").text(Validator.COMPANY_URL_TOO_LONG);
					return false;
				}
				return true;
			}	
			function validMobile() {
				var mobile =  $.trim($("#mobile").val());
				if ("" != mobile) {
					if (!Validator.isMobileNum(mobile)) {
					    $("#err_reg_mobile").css("display","block");
						$("#err_reg_mobile").text(Validator.VALID_MOBILE_NUM);
						return false;
				   }
				}
			   return true;
			}	
		   function validRegVercode() {
		     	var strm = $.trim($("#vercode").val());
				if(""==strm) {
				    $("#err_reg_vercode").css("display","block");
					$("#err_reg_vercode").text(Validator.IS_REQUIRED + "验证码");
					return false;
				}
				return true;
		   }	
		   function validIsAgree() {
		    	var flag = $("#isAgree").checked;
		    	$("#err_reg_isAgree").css("display","block");
				if (flag == false) {
					$("#err_reg_isAgree").text(Validator.DONT_AGREE);
					 return false;
				}
				clearIsAgreeErrMsg();
				return true;
		   }	   
		   	function checkParams() {
		   		var r1 = validRegEmail();
		   		var r2 = validRegPwd();
		   		var r3 = validConfimPwd();
		   		var r4 = validComName();
		   		var r5 = validComUrl();
		   		var r6 = validMobile();
		   		
		   		return r1 && r2 && r3 && r4 && r5 && r6;
			}
			function clearRegEmailErrMsg(){$("#err_reg_email").css("display","none");}
			function clearRegPwdErrMsg(){$("#err_reg_pwd").css("display","none");}		
			function clearConfimPwdErrMsg(){
				$("#err_reg_confimPwd").css("display","none");
			}		
			function clearComNameErrMsg() {
				$("#err_reg_comName").css("display","none");
			}		
			function clearComUrlErrMsg() {
				$("#err_reg_comUrl").css("display","none");
			}		
			function clearMobileErrMsg() {
				$("#err_reg_mobile").css("display","none");
			}
			function clearReferrerEmailErrMsg() {
				$("#err_reg_referrerEmail").css("display","none");
			}
			function clearRegVercodeErrMsg() {
			$("#err_reg_vercode").css("display","none");
			}
			function clearIsAgreeErrMsg() {
			    $("#err_reg_isAgree").css("display","none");
			}	
			/**
			 * 刷新图片验证码
			 */
			function refreshRegcode(){
				document.getElementById("vercode").value="";
				document.getElementById("vercode").focus();
				var verify=document.getElementById('imgVerCode');
				verify.setAttribute('src', '/user/genVcode?t=' + Math.random());
			}
		
			/**
			 * 默认的邮箱格式样例
			 */
			var SAMPLE_EMAIL = "请在此输入的你的邮箱";
			var SAMPLE_EMAIL_COLOR = "#aaa";
			var EMAIL_COLOR = "#494949";
			function cleanDefEmail() {
				if ($("#email").val() == SAMPLE_EMAIL) {
					$("#email").val("").css("color", EMAIL_COLOR);
				}
			}
		
			function setDefEmail() {
				if ($("#email").val() == "") {
					$("#email").val(SAMPLE_EMAIL).css("color", SAMPLE_EMAIL_COLOR);
				}
			}	
		</script>

	<div class="content">
		<div class="page_url"><a href="<?php echo base_url();?>">首页</a> 
		<span>&gt;</span> <strong>用户注册</strong>
		</div>
		<div class="main_box">
			<div class="main_box_top">
				<div class="main_box_bottom">
					<h2 class="page_title">用户注册</h2>
					<div class="sso_info">
						<!-- 
						<div class="sso_steps" >
								<ul>
									<li class="cur"><em>1</em><span>填写用户信息</span></li>
									<li><em>2</em><span>通过邮箱激活帐号</span></li>
									<li><em>3</em><span>注册完成</span></li>
								</ul>
						</div>
						 -->
						<div style="height: 30px;margin: 10px auto 25px;padding-top: 50px;width: 600px;"></div>
						
						<div class="error_msg" style="display:none;"></div>
						<div class="reg_main">
						    <form method="post" action="<?php echo base_url('user/register');?>" id="reg_form" onsubmit="return checkParams()">
								<ul>
									<li class="bz">
										<label>邮箱帐号：</label>
										<input class="input_text" id="email" name="user[email]" type="text" value="<?php if(isset($formInfo)){echo $formInfo['email'];}?>" onfocus="javascript:clearRegEmailErrMsg()" onblur="javascript:validRegEmail();" style="color: rgb(170, 170, 170); " maxlength="50">
										<b>*</b>
										<span class="bz_tips">强烈推荐您填写公司邮箱账号，以确保您得到最优质的服务体验</span> 
										<span id="err_reg_email" class="error_tips" style="display:none;"></span> 
									</li>								
									<li class="bz">
										<label>密码：</label>
										<input class="input_text" id="pwd" name="user[password]" type="password" value="" onfocus="javascript:clearRegPwdErrMsg()" onblur="javascript:validRegPwd();" maxlength="16">
										<b>*</b>
										<span class="bz_tips">请输入6～16位数字+字母组合</span>
										<span id="err_reg_pwd" class="error_tips" style="display:none;"></span> 
									</li>
									<li>
										<label>确认密码：</label>
										<input class="input_text" id="confimPwd" name="user[confimPwd]" type="password" value="" onfocus="javascript:clearConfimPwdErrMsg()" onblur="javascript:validConfimPwd();" maxlength="16">
										<b>*</b>
										<span id="err_reg_confimPwd" class="error_tips" style="display:none;"></span> 
									</li>
									<li>
										<label>公司名称：</label>
						       			<input class="input_text" id="comName" name="user[company]" type="text" value="<?php if(isset($formInfo)){ echo $formInfo['company'];} ?>" onfocus="javascript:clearComNameErrMsg()" onblur="javascript:validComName();" maxlength="50">
						      			<span id="err_reg_comName" class="error_tips" style="display:none;"></span> 
									</li>								
									<li>
										<label>网站地址：</label>
						       			<input class="input_text" id="comUrl" name="user[company_url]" type="text" value="<?php if(isset($formInfo)){ echo $formInfo['company_url'];} ?>" onfocus="javascript:clearComUrlErrMsg()" onblur="javascript:validComUrl();" maxlength="200">
						        		<span id="err_reg_comUrl" class="error_tips" style="display:none;"></span> 
									</li>								
									<li>
										<label>手机号码：</label>
						        		<input class="input_text" id="mobile" name="user[mobile]" type="text" value="<?php if(isset($formInfo)){ echo $formInfo['mobile'];} ?>" onfocus="javascript:clearMobileErrMsg()" onblur="javascript:validMobile();" maxlength="20">
						        		<span id="err_reg_mobile" class="error_tips" style="display:none;"></span>  
									</li>			
									<li class="check_code">
										<label>验证码：</label>
						        		<input class="input_text" id="vercode" name="vercode" type="text" value="" onfocus="javascript:clearRegVercodeErrMsg()" onblur="javascript:validRegVercode();" maxlength="4">
						         		<a href="#" onclick="refreshRegcode();" title="换一张">
						         			<img id="imgVerCode" name="imgVerCode" src="/user/genVcode" width="90" height="25" alt="">
						         			<em>换一张</em>
						         		</a>
						         		<b>*</b>
						         		<span id="err_reg_vercode" class="error_tips" style="display:none;"></span>
									</li>								
									<li class="reg_agreement">
										<label>&nbsp;</label>
										<label style="margin-left:120px;width:500px;display:inline;text-align:left;">
										<input id="isAgree" type="checkbox" name="isAgree" value="1" checked="">
										<span>我已阅读并同意《<a href="<?php echo base_url('user/agreement')?>" target="_blank">服务协议</a>》</span>
										</label>
									</li>
								</ul>
								<div class="ljzc_bt">
									<button id="reg_submit" type="submit" value="">注册</button>
								</div>
					    	</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php $this->load->view('footer')?>